package com.zzyl.nursing.controller.member;

import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.core.domain.R;
import com.zzyl.nursing.dto.DevicePropertyStatusDto;
import com.zzyl.nursing.dto.QueryDeviceDataDto;
import com.zzyl.nursing.dto.UserDto;
import com.zzyl.nursing.dto.UserLoginRequestDto;
import com.zzyl.nursing.service.IDeviceDataService;
import com.zzyl.nursing.service.IFamilyMemberService;
import com.zzyl.nursing.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 老人家属Controller
 * 
 * @author ruoyi
 * @date 2025-04-26
 */
@RestController
@RequestMapping("/member/user")
@Api(tags = "老人家属的接口")
@Slf4j
public class FamilyMemberController extends BaseController
{
    @Autowired
    private IFamilyMemberService familyMemberService;

    @Autowired
    private IDeviceDataService  deviceDataService;

    @PostMapping("/login")
    public AjaxResult login(@RequestBody UserLoginRequestDto dto){
        LoginVo vo = familyMemberService.login(dto);
        return success(vo);
    }

    /**
     * 绑定家人
     */
    @PostMapping("/add")
    @ApiOperation("绑定家人")
    public AjaxResult add(@RequestBody UserDto userDto) {
        familyMemberService.add(userDto);
        return success();
    }


    /**
     * 查询家人列表
     *
     * @return List<UserVo>
     */
    @GetMapping("/my")
    public R<List<UserVo>> my() {
        return R.ok(familyMemberService.my());
    }



    /**
     * 查看已绑定家人列表
     *
     * @return TableDataInfo<MemberVo>
     */
    @GetMapping("/list-by-page")
    public R<List<MemberVo>> listByPage() {
        startPage();
        List<MemberVo> memberVoList = familyMemberService.listByPage();
        return R.ok(memberVoList);
    }

    @PostMapping("/QueryDevicePropertyStatus")
    @ApiOperation("查询设备属性状态")
    public R ListVo (@RequestBody DevicePropertyStatusDto devicePropertyStatusDto) {
        ListVo list = familyMemberService.queryDevicePropertyStatus(devicePropertyStatusDto);
        return R.ok(list);
    }

    /**
     * 按天查询设备物模型数据
     * @param queryDeviceDataDto
     * @return
     */
    @GetMapping("/queryDeviceDataListByDay")
    @ApiOperation("按天查询设备物模型数据")
    public R<List<QueryDeviceDateVo>> queryDeviceDataListByDay (QueryDeviceDataDto queryDeviceDataDto) {
        log.info("查询设备数据列表:{}", queryDeviceDataDto);
        List<QueryDeviceDateVo> list = deviceDataService.queryDeviceDataListByDay(queryDeviceDataDto);
        return R.ok(list);
    }

    /**
     * 按天查询设备物模型数据
     * @param queryDeviceDataDto
     * @return
     */
    @GetMapping("/queryDeviceDataListByWeek")
    @ApiOperation("按周查询设备物模型数据")
    public R<List<QueryDeviceDateVo>> queryDeviceDataListByWeek (QueryDeviceDataDto queryDeviceDataDto) {
        log.info("按周查询设备数据列表:{}", queryDeviceDataDto);
        List<QueryDeviceDateVo> list = deviceDataService.queryDeviceDataListByWeek(queryDeviceDataDto);
        return R.ok(list);
    }


}
